﻿using System.Collections.ObjectModel;
using Prompts.Prompting.ViewModels;
using Prompts.Prompting.ViewModels.Implementation;

namespace Prompts.Prompting.Construction.Implementation
{
    public class CasscadingSearchProvider : ICasscadingSearchProvider
    {
        private readonly IAsynchronousSearchServiceBuilder _asynchronousSearchServiceBuilder;

        public CasscadingSearchProvider(IAsynchronousSearchServiceBuilder asynchronousSearchServiceBuilder)
        {
            _asynchronousSearchServiceBuilder = asynchronousSearchServiceBuilder;
        }

        public IMultiSelectPrompt Get(string label, string promptName, string parameterName)
        {
            var searchService = _asynchronousSearchServiceBuilder.Build(promptName, parameterName);

            return new MultiSelectCasscadingSearch(
                label
                , promptName
                , searchService
                , new ObservableCollection<IPromptItem>());
        }
    }
}
